package com.woniuxy.mapper;

import com.woniuxy.pojo.Department;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author admin
* @description 针对表【department(科室表（合并一级和二级科室）)】的数据库操作Mapper
* @createDate 2025-05-29 19:14:16
* @Entity com.woniuxy.pojo.Department
*/
@Mapper
public interface DepartmentMapper extends BaseMapper<Department> {
    @Select("<script>" +
            "SELECT id FROM department d " +
            "WHERE 1=1 " +
            "<if test='name != null and name != \"\"'>" +
            "   AND EXISTS (" +
            "       SELECT 1 FROM department p WHERE p.id = d.parent_id AND p.name LIKE CONCAT('%', #{name}, '%')" +
            "   )" +
            "   OR d.name LIKE CONCAT('%', #{name}, '%')" +
            "</if>" +
            "</script>")
    List<Integer> findIdsByName(String departmentName);
}




